package com.gin.kotlin.no_gay_alliance.database.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.gin.kotlin.no_gay_alliance.database.entity.NgaAccount

@Dao
interface NgaAccountDao {
    @Insert(onConflict = OnConflictStrategy.IGNORE)
    fun add(ngaAccount: NgaAccount)

    @Insert(onConflict = OnConflictStrategy.IGNORE)
    fun add(ngaAccount: List<NgaAccount>)

    @Query("select * from NgaAccount")
    fun list(): List<NgaAccount>
    @Update
    fun update(ngaAccount: NgaAccount):Int
    @Query("delete from NgaAccount where userId=:userId")
    fun delete(userId:Long):Int

    @Query("update NgaAccount set enable = 0")
    fun clearEnable():Int

    @Query("update NgaAccount set enable = 1 where userId=:userId")
    fun setEnable(userId: Long):Int

    @Query("select * from  NgaAccount where userId=:userId")
    fun getByUserId(userId: Long): NgaAccount?

}